{% extends base.html %}
<!--
@author xupingmao
@since 2017/11/29
@modified 2021/12/04 21:13:05
-->

{% block body %}

    <div class="card">
        <div class="card-title">
            <span>搜索历史</span>

            <div class="float-right">
                <a class="btn btn-default" href="/system/settings?category=search">搜索设置</a>
                {% include common/button/back_button.html %}
            </div>
        </div>
    </div>

    <div class="card">
        {% if len(recent) == 0 %}
            {% include common/text/empty_text.html %}
        {% end %}

        {% for value in recent %}
            <a class="tag-span" href="/search?key={{quote(value)}}">{{value}}</a>
        {% end %}

        {% if len(recent) > 0 %}
            <a class="tag-span-danger clear-history-link">清空历史记录</a>
        {% end %}
    </div>

<script type="text/javascript">
    $(".clear-history-link").click(function (e) {
        xnote.confirm("确定清空历史记录吗?", function (resp) {
            $.post("/search/history?p=clear", function(resp) {
                if (resp.code == "success") {
                    location.reload();
                } else {
                    xnote.alert(resp.message);
                }
            });
        });
    })
</script>
{% end %}